package com.home.duy.code.components;

import java.io.File;

import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.filechooser.FileView;

import com.home.Common.Common;
import com.home.Common.Resources_Duy;
import com.home.duy.code.Helper.UtilsFileImage;

public class ImageFileView extends FileView{
	ImageIcon pngIcon = Common.getImageIcon(Resources_Duy.ICON_PATH+"png.png");
	ImageIcon gifIcon = Common.getImageIcon(Resources_Duy.ICON_PATH+"gif.png");
	ImageIcon jpgIcon = Common.getImageIcon(Resources_Duy.ICON_PATH+"jpg.png");
	
	public String getName(File f)
	{
		return null;
	}
	
	public String getDescription(File f)
	{
		return null;
	}
	
	public Boolean isTraverable(File f)
	{
		return null;
	}
	
	public String getTypeDescription(File f)
	{
		String ext = UtilsFileImage.getExtension(f);
		String type = null;
		
		if(ext != null)
		{
			if(ext.equals(UtilsFileImage.jpg) || ext.equals(UtilsFileImage.jpeg))
			{
				type = "JPEG Image";
			}
			else if(ext.equals(UtilsFileImage.gif))
			{
				type = "GIF Image";
			}
			else if(ext.equals(UtilsFileImage.png))
			{
				type = "PNG Image";
			}
		}
		return type;
	}
	
	public Icon getIcon(File f)
	{
		String ext = UtilsFileImage.getExtension(f);
		Icon icon = null;
		if(ext != null)
		{
			if(ext.equals(UtilsFileImage.jpg) || ext.equals(UtilsFileImage.jpeg))
			{
				icon = jpgIcon;
			}
			else if(ext.equals(UtilsFileImage.gif))
			{
				icon = gifIcon;
			}
			else if(ext.equals(UtilsFileImage.png))
			{
				icon = pngIcon;
			}
		}
		return icon;
	}
}
